package com.cq.hd.app.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: mybatis plus 配置类
 * @author: mYunYu
 *  2021/7/8 14:28
 * @version: v1.0
 */
@Configuration
@MapperScan(basePackages = "com.cq.hd.app.mapper")
public class MybatisPlusConfig {

    /**
     * @Description: 分页插件
     * @Param: []
     * @Return: com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
     * @Auther: mYunYu
     *  2021/7/8 14:28
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * @Description: 乐观锁插件 实体使用 @Version 标记
     * @Param: []
     * @Return: com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor
     * @Auther: mYunYu
     *  2021/7/8 14:28
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }

}
